<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>9.24 课堂练习</title>
</head>

<body>
    <script>
        let num = [1, 5, 2]
        let number = num.reduce((x, y) => x * y)
        console.log(number)

        let str = ['Mary', ' ', 'Make', ' ', '!']
        let resStr = str.reduce((acc, word) => acc + word)
        console.log(resStr)

        let arr = [{
            x: 1
        }, {
            x: 5
        }, {
            x: 2
        }, {
            x: 3
        }, {
            x: 7
        }]
        let resArr = arr.reduce((acc, cur) => acc + cur.x, 0)
        console.log(resArr)
        console.log("\n")

        num = [4, 9, 5, 7, 1]
        for (let i = 0; i < num.length; ++i) {
            console.log(num[i])
        }
        console.log("\n")

        for (let i in num) {
            console.log(num[i])
        }
        console.log("\n")

        for (let n of num) {
            console.log(n)
        }
        console.log("\n")
    </script>
</body>

</html>